package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingPlanDto;
import com.zzyl.service.NursingPlanService;
import com.zzyl.vo.NursingPlanVo;
import com.zzyl.vo.NursingProjectVo;
import com.zzyl.vo.PageVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apiguardian.api.API;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/nursing/plan")
@Api(tags = "护理计划")
public class NursingPlanController {
    @Autowired
    private NursingPlanService nursingPlanService;

    @GetMapping("/search")
    @ApiOperation("护理计划分页查询")
    public ResponseResult<PageVo> getNursingPlanPageList(NursingPlanDto nursingPlanDto){
        PageResponse<NursingPlanVo> nursingPlanVoList = nursingPlanService.getNursingPlanPageList(nursingPlanDto);
        return ResponseResult.success(nursingPlanVoList);
    }

    @GetMapping
    @ApiOperation("查询所有护理计划")
    public ResponseResult<List<NursingPlanVo>> getNursingPlanList(){
        List<NursingPlanVo> nursingPlanVoList = nursingPlanService.getNursingPlanList();
        return ResponseResult.success(nursingPlanVoList);
    }


    @PostMapping
    @ApiOperation("新增护理计划")
    public ResponseResult addNursingPlan(@RequestBody NursingPlanDto nursingPlanDto){
        System.out.println(nursingPlanDto.toString());
        nursingPlanService.addNursingPlan(nursingPlanDto);
        return ResponseResult.success();
    }


    @PutMapping("{id}/status/{status}")
    @ApiOperation("启用禁用护理计划")
    public ResponseResult updateNursingPlanStatusById(@PathVariable Long id,@PathVariable Integer status){
        nursingPlanService.updateNursingPlanStatusById(id,status);
        return ResponseResult.success();
    }

    @DeleteMapping("{id}")
    @ApiOperation("删除护理计划")
    public ResponseResult deleteNursingPlanById(@PathVariable Long id){
        nursingPlanService.deleteNursingPlanById(id);
        return ResponseResult.success();
    }

    @GetMapping("{id}")
    @ApiOperation("查询回显")
    public ResponseResult getNursingPlanById(@PathVariable Long id){
        NursingPlanVo nursingProjectPlanVo = nursingPlanService.getNursingPlanById(id);
        return ResponseResult.success(nursingProjectPlanVo);
    }

    @PutMapping("{id}")
    @ApiOperation("修改护理计划")
    public ResponseResult updateNursingPlanById(@PathVariable Long id,@RequestBody NursingPlanDto nursingPlanDto){
        nursingPlanService.updateNursingPlanById(id,nursingPlanDto);
        return ResponseResult.success();
    }
}
